package org.webequa.core.maple.operator.algebra;

import org.apache.log4j.Logger;
import org.webequa.core.common.operator.algebra.Divide;
import org.webequa.core.maple.operator.MapleBinaryOperator;
import org.webequa.core.maple.quantity.MapleQuantityObject;
import org.webequa.core.maple.quantity.MapleQuantityObjectFactory;

import com.maplesoft.externalcall.MapleException;
import com.maplesoft.openmaple.Algebraic;

public class MapleDivide extends MapleBinaryOperator implements Divide
{
	@Override
	public void calculate()
	{				
		try
		{
			MapleQuantityObject tOp1 = MapleQuantityObjectFactory.getMapleQuantityObject(operand1);
			MapleQuantityObject tOp2 = MapleQuantityObjectFactory.getMapleQuantityObject(operand2);
			String mapleJob = tOp1.getVarName()+"/"+tOp2.getVarName()+":";				
			Algebraic tRes = mapleEngine.evaluate(mapleJob);
			log.info(mapleJob);			
			res = MapleQuantityObjectFactory.getMapleQuantityObject(getResultSignature(),tRes);
		} catch (MapleException e)
		{
			log.error(e);
			res = null;
		}
	}	
	
	private static final Logger log = Logger.getLogger(MapleDivide.class);
}
